package com.minisoft.goodanchor;

import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import cn.hutool.log.dialect.console.ConsoleLog;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author JueSu
 * @description: TODO
 * @date 2022/5/30 8:59
 */
public class Read {

    static int activityId = 629;

    @Test
    public void testShareIcon() {
        ExcelReader reader = ExcelUtil.getReader("C:\\Users\\31594\\Downloads\\临时表格（好主播）.xlsx");
        List<Map<String, Object>> rows = reader.readAll();
        List<String> accountUpadateList = new ArrayList<>();
        List<String> actUpadateList = new ArrayList<>();
        for (Map<String, Object> row : rows) {
            accountUpadateList.add(StrUtil.format("update short_video_account set share_icon = '{}' where id = {};",row.get("share_icon"),row.get("id")));
            actUpadateList.add(StrUtil.format("UPDATE promotion_activity_partake_log l set l.share_icon = '{}' where l.activity_id = {} and l.user_id = {};",row.get("share_icon"),activityId,row.get("id")));
        }

        accountUpadateList.forEach(Console::log);
        System.out.println("更新活动数据：");
        actUpadateList.forEach(Console::log);
//        Console.log(rows);
    }
    @Test
    public void testOpenid() {
        ExcelReader reader = ExcelUtil.getReader("C:\\Users\\31594\\Downloads\\临时表格（好主播）.xlsx",1);
        List<Map<String, Object>> rows = reader.readAll();
        for (Map<String, Object> row : rows) {
            Console.log("update short_video_account set subject_id = '{}' where id = {};",row.get("subject_id"),row.get("id"));
        }
//        rows.forEach(Console::log);
//        Console.log(rows);
    }
}
